/*
Copyright © 2022 NAME HERE <EMAIL ADDRESS>

*/
package cmd

import (
	"fmt"
	"github.com/spf13/cobra"
	"operator/cicd/util"
)

// initCmd represents the init command
var initCmd = &cobra.Command{
	Use:   "init",
	Short: "init a project",
	Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
	Run: func(cmd *cobra.Command, args []string) {
		config := util.GetConfigFromCmd(cmd)
		err := config.Save()
		if err != nil {
			fmt.Println(err)
		}
	},
}

func init() {
	rootCmd.AddCommand(initCmd)
	initCmd.Flags().StringP("path", "p", "./", "the project path")
	initCmd.Flags().StringP("targetOs", "o", "linux", "project run target os")
	initCmd.Flags().StringP("targetArch", "a", "amd64", "project run target arch")
	initCmd.Flags().StringP("execName", "e", "run", "the binary name")
	initCmd.Flags().StringP("version", "v", "latest", "the version of image")
	initCmd.Flags().StringP("image", "i", "run", "the name of image")
	initCmd.Flags().StringP("serverAddr", "s", "https://index.docker.io/v1/", "docker hub addr")
}
